package com.sc.service.impl.csm;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.sc.domain.Employee;
import com.sc.dto.EmployeeDTO;
import com.sc.mapper.csm.EmployeeMapper;
import com.sc.result.PageResult;
import com.sc.service.csm.IEmployeeService;
import com.sc.vo.EmployeeVO;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class EmployeeServiceImpl extends ServiceImpl<EmployeeMapper, Employee> implements IEmployeeService {

    @Override
    public PageResult<EmployeeVO> pageQuery(EmployeeDTO employeeDTO) {
        int start = (employeeDTO.getPageNum() - 1) * employeeDTO.getPageSize();
        int end = employeeDTO.getPageNum() * employeeDTO.getPageSize();

        List<EmployeeVO> list = baseMapper.pageQuery(employeeDTO);
        PageResult<EmployeeVO> page = new PageResult<>(list.size(), list.subList(start, Math.min(list.size(), end)));
        return page;
    }
}
